import pygame

goomba_run1 = pygame.image.load(r"Img/GooBa/goomba_run_01.png")
goomba_run2 = pygame.image.load(r"Img/GooBa/goomba_run_02.png")
goomba_run1 = pygame.transform.scale(goomba_run1, (38, 38))
goomba_run2 = pygame.transform.scale(goomba_run2, (38, 38))
goomba_death = pygame.image.load(r"Img/GooBa/goomba_death.png")
goomba_run = [goomba_run1, goomba_run2]


class GoomBa(pygame.sprite.Sprite):
    def __init__(self, pos):
        pygame.sprite.Sprite.__init__(self)
        self.image = goomba_run1
        self.rect = self.image.get_rect()
        self.rect.x = pos[0]
        self.rect.y = pos[1]
        self.run_current = 0
        self.speed = 5
        self.now_x = 0
        self.is_death = False
        self.is_death_num = 0
        self.alive = False
        self.bg_move = 0

    def death(self):
        self.image = pygame.transform.scale(goomba_death, (38, 38))
        self.is_death = True
        self.speed = 0

    def run(self):
        self.run_current += 1
        if self.is_death is False:
            self.rect.x -= self.speed
        if self.run_current >= len(goomba_run):
            self.run_current = 0
        self.image = goomba_run[self.run_current]
